#ifndef TCPSERVER_H
#define TCPSERVER_H
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <fcntl.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <cassert>
#include <sys/epoll.h>
#include <sys/types.h>
#include <iostream>
#include "../tcpconn/tcpconn.h"
#include "../threadpool/threadpool.h"
#include "../sqlpool/sql.h"

#define MAX_FD 65536
#define MAX_EVENT_NUMBER 10000
#define PORT 9600

extern int addfd(int epollfd, int fd, bool one_shot);
extern int removefd(int epollfd, int fd);

class tcpserver{
public:
    tcpserver();
    ~tcpserver();
    void sqlpool_init();
    void threadpool_init();
    void event_listen();
    void epoll_run();

private:
    string m_user;
    string m_passwd ;
    string m_databasename;
    tcpconn *m_users;
    connection_pool *m_connpool;
    threadpool<tcpconn> *m_threadpool;

    int m_user_count;
    int m_listenfd;
    int m_epollfd;
};

#endif
